home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_tkcvs.idb / usr / freeware / lib / tkcvs / search.tcl.z / search.tcl
Encoding:
Text File  |  1999-04-16  |  6.1 KB  |  252 lines

  1. #
  2. # Tcl Library for tkCVS
  3. #
  4.  
  5. #
  6. # $Id: search.tcl,v 1.3 1995/08/19 11:47:31 del Exp $
  7. #
  8. # Set up some search dialogs.
  9. #
  10.  
  11. proc search_setup {} {
  12.  
  13.   toplevel .search1
  14.   frame .search1.left
  15.   frame .search1.right
  16.   frame .search1.down -relief groove -border 2
  17.  
  18.   pack .search1.down -side bottom -fill x
  19.   pack .search1.left -side left -fill y
  20.   pack .search1.right -side left -fill both -expand 1
  21.  
  22.   label .search1.lname -text "Search for Code" -anchor w
  23.  
  24.   entry .search1.tname -relief sunken -textvariable search1name
  25.  
  26.   # bind_motifentry .search1.tname
  27.  
  28.   pack .search1.lname -in .search1.left \
  29.     -side top -fill x -pady 3
  30.  
  31.   pack .search1.tname -in .search1.right \
  32.     -side top -fill x -pady 3
  33.  
  34.   button .search1.ok -text "OK" \
  35.     -command {
  36.       eval "run_search1 $search1name"
  37.       wm withdraw .search1
  38.     }
  39.   button .search1.quit -text "Quit" -command { wm withdraw .search1 }
  40.  
  41.   pack .search1.ok .search1.quit -in .search1.down -side left \
  42.     -ipadx 2 -ipady 2 -padx 4 -pady 4 -fill both -expand 1
  43.  
  44.   wm withdraw .search1
  45.   wm title .search1 "Search for Module Code"
  46.   wm minsize .search1 1 1
  47.  
  48.   toplevel .search2
  49.   frame .search2.left
  50.   frame .search2.right
  51.   frame .search2.down -relief groove -border 2
  52.  
  53.   pack .search2.down -side bottom -fill x
  54.   pack .search2.left -side left -fill y
  55.   pack .search2.right -side left -fill both -expand 1
  56.  
  57.   label .search2.lname -text "Search for Name" -anchor w
  58.  
  59.   entry .search2.tname -relief sunken -textvariable search2name
  60.  
  61.   # bind_motifentry .search2.tname
  62.  
  63.   pack .search2.lname -in .search2.left \
  64.     -side top -fill x -pady 3
  65.  
  66.   pack .search2.tname -in .search2.right \
  67.     -side top -fill x -pady 3
  68.  
  69.   button .search2.ok -text "OK" \
  70.     -command {
  71.       eval "run_search2 $search2name"
  72.       wm withdraw .search2
  73.     }
  74.   button .search2.quit -text "Quit" -command { wm withdraw .search2 }
  75.  
  76.   pack .search2.ok .search2.quit -in .search2.down -side left \
  77.     -ipadx 2 -ipady 2 -padx 4 -pady 4 -fill both -expand 1
  78.  
  79.   wm withdraw .search2
  80.   wm title .search2 "Search for Module Name"
  81.   wm minsize .search2 1 1
  82.  
  83.   toplevel .search3
  84.   frame .search3.left
  85.   frame .search3.right
  86.   frame .search3.down -relief groove -border 2
  87.  
  88.   pack .search3.down -side bottom -fill x
  89.   pack .search3.left -side left -fill y
  90.   pack .search3.right -side left -fill both -expand 1
  91.  
  92.   label .search3.lname -text "Search for Keyword" -anchor w
  93.  
  94.   entry .search3.tname -relief sunken -textvariable search3name
  95.  
  96.   # bind_motifentry .search3.tname
  97.  
  98.   pack .search3.lname -in .search3.left \
  99.     -side top -fill x -pady 3
  100.  
  101.   pack .search3.tname -in .search3.right \
  102.     -side top -fill x -pady 3
  103.  
  104.   button .search3.ok -text "OK" \
  105.     -command {
  106.       eval "run_search3 $search3name"
  107.       wm withdraw .search3
  108.     }
  109.   button .search3.quit -text "Quit" -command { wm withdraw .search3 }
  110.  
  111.   pack .search3.ok .search3.quit -in .search3.down -side left \
  112.     -ipadx 2 -ipady 2 -padx 4 -pady 4 -fill both -expand 1
  113.  
  114.   wm withdraw .search3
  115.   wm title .search3 "Search for Keyword"
  116.   wm minsize .search3 1 1
  117.  
  118. }
  119.  
  120. proc code_search {} {
  121.   global dtitle
  122.   global mtitle
  123.  
  124.   if {! [info exists dtitle]} {
  125.     cvserror "You do not have any #D lines in your modules file."
  126.     return
  127.   }
  128.   if {! [info exists mtitle]} {
  129.     cvserror "You do not have any #M lines in your modules file."
  130.     return
  131.   }
  132.  
  133.   wm deiconify .search1
  134. }
  135.  
  136. proc name_search {} {
  137.   global dtitle
  138.   global mtitle
  139.  
  140.   if {! [info exists dtitle]} {
  141.     cvserror "You do not have any #D lines in your modules file."
  142.     return
  143.   }
  144.   if {! [info exists mtitle]} {
  145.     cvserror "You do not have any #M lines in your modules file."
  146.     return
  147.   }
  148.  
  149.   wm deiconify .search2
  150. }
  151.  
  152. proc keyword_search {} {
  153.   global dtitle
  154.   global mtitle
  155.  
  156.   if {! [info exists dtitle]} {
  157.     cvserror "You do not have any #D lines in your modules file."
  158.     return
  159.   }
  160.   if {! [info exists mtitle]} {
  161.     cvserror "You do not have any #M lines in your modules file."
  162.     return
  163.   }
  164.  
  165.   wm deiconify .search3
  166. }
  167.  
  168. proc run_search1 {code} {
  169.  
  170.   global mtitle
  171.   global dcontents
  172.  
  173.   if [info exists mtitle($code)] {
  174.     .viewer.text configure -state normal
  175.     .viewer.text delete 1.0 end
  176.     foreach subdir [array names dcontents] {
  177.       if {[lsearch -exact $dcontents($subdir) $code] != -1} {
  178.         .viewer.text insert end "Parent Directory :  $subdir\n"
  179.       }
  180.     }
  181.     .viewer.text insert end "Module Code      :  $code\n"
  182.     .viewer.text insert end "Module Name      :  $mtitle($code)\n"
  183.     .viewer.text configure -state disabled
  184.     wm deiconify .viewer
  185.   } else {
  186.     cvsfail "Module $code not found."
  187.   }
  188. }
  189.  
  190. proc run_search2 {name} {
  191.  
  192.   global mtitle
  193.   global dcontents
  194.  
  195.   .viewer.text configure -state normal
  196.   .viewer.text delete 1.0 end
  197.   set counter 0
  198.  
  199.   foreach code [array names mtitle] {
  200.     if [string match [string tolower $name] [string tolower $mtitle($code)]] {
  201.       foreach subdir [array names dcontents] {
  202.         if {[lsearch -exact $dcontents($subdir) $code] != -1} {
  203.           .viewer.text insert end "Parent Directory :  $subdir\n"
  204.         }
  205.       }
  206.       .viewer.text insert end "Module Code      :  $code\n"
  207.       .viewer.text insert end "Module Name      :  $mtitle($code)\n\n"
  208.       set counter 1
  209.     }
  210.   }
  211.  
  212.   if {$counter} {
  213.     .viewer.text configure -state disabled
  214.     wm deiconify .viewer
  215.   } else {
  216.     cvsfail "Module $name not found."
  217.   }
  218. }
  219.  
  220. proc run_search3 {name} {
  221.  
  222.   global mtitle
  223.   global dcontents
  224.  
  225.   .viewer.text configure -state normal
  226.   .viewer.text delete 1.0 end
  227.   set counter 0
  228.  
  229.   foreach code [array names mtitle] {
  230.     if [ expr \
  231.       {[string first [string tolower $name] [string tolower $code]] != -1} || \
  232.       {[string first [string tolower $name] [string tolower $mtitle($code)]] \
  233.         != -1 }] {
  234.       foreach subdir [array names dcontents] {
  235.         if {[lsearch -exact $dcontents($subdir) $code] != -1} {
  236.           .viewer.text insert end "Parent Directory :  $subdir\n"
  237.         }
  238.       }
  239.       .viewer.text insert end "Module Code      :  $code\n"
  240.       .viewer.text insert end "Module Name      :  $mtitle($code)\n\n"
  241.       set counter 1
  242.     }
  243.   }
  244.  
  245.   if {$counter} {
  246.     .viewer.text configure -state disabled
  247.     wm deiconify .viewer
  248.   } else {
  249.     cvsfail "Module containing $name not found."
  250.   }
  251. }
  252.